<template>
  <view class="delivery-progress-container">
    <!-- 固定顶部区域 -->
    <view class="fixed-header">
      <!-- 顶部导航 -->
      <view class="header">
        <view class="back-button" @click="goBack">
          <image class="back-icon" src="/static/back.png"></image>
        </view>
        <text class="page-title">投递进度</text>
      </view>

      <!-- 筛选按钮 -->
      <view class="filter-container">
        <view class="filter-buttons">
          <view
            v-for="(tab, index) in statusTabs"
            :key="index"
            :class="['filter-btn', { active: currentStatus === tab.value }]"
            @click="selectStatus(tab.value)"
          >
            {{ tab.label }}
          </view>
        </view>
      </view>
    </view>

    <!-- 可滚动内容区域 -->
    <view class="progress-list-scroll">
      <view class="progress-container">
        <view class="progress-list">
          <view
            v-for="progress in filteredProgressList"
            :key="progress.id"
            class="progress-card"
            @click="goToJobDetail(progress.jobId)"
          >
            <view class="job-title-row">
              <text class="job-title">{{ progress.jobTitle }}</text>
              <text class="job-salary">{{ progress.salary }}</text>
            </view>
            <view class="job-company-row">
              <text class="company">{{ progress.company }}</text>
              <text :class="['tag', progress.statusClass]">{{ progress.statusLabel }}</text>
            </view>
            <view class="job-meta">
              <text class="meta">{{ progress.deliveryDate }}</text>
              <text class="meta">{{ progress.location }}</text>
            </view>
          </view>

          <!-- 空状态 -->
          <view v-if="filteredProgressList.length === 0" class="empty-state">
            <text class="empty-icon">📭</text>
            <text class="empty-text">暂无投递记录</text>
            <text class="empty-desc">快去寻找心仪的工作机会吧</text>
            <button class="publish-btn" @click="goToJobSearch">去找工作</button>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      currentStatus: 'all',
      statusTabs: [
        { label: '全部', value: 'all' },
        { label: '已投递', value: 'delivered' },
        { label: '已查看', value: 'viewed' },
        { label: '通过初筛', value: 'interview' },
        { label: '不合适', value: 'rejected' }
      ],
      progressList: [
        {
          id: '1',
          jobId: 'job1',
          jobTitle: '前端开发工程师',
          company: '字节跳动',
          salary: '20k-35k',
          status: 'interview',
          statusLabel: '通过初筛',
          statusClass: 'interviewed',
          deliveryDate: '2024-01-15',
          location: '北京',
          jobType: '全职'
        },
        {
          id: '2',
          jobId: 'job2',
          jobTitle: '产品经理',
          company: '腾讯',
          salary: '25k-40k',
          status: 'viewed',
          statusLabel: '已查看',
          statusClass: 'delivered',
          deliveryDate: '2024-01-14',
          location: '深圳',
          jobType: '全职'
        },
        {
          id: '3',
          jobId: 'job3',
          jobTitle: 'UI设计师',
          company: '阿里巴巴',
          salary: '18k-30k',
          status: 'pending',
          statusLabel: '待查看',
          statusClass: 'pending',
          deliveryDate: '2024-01-13',
          location: '杭州',
          jobType: '全职'
        },
        {
          id: '4',
          jobId: 'job4',
          jobTitle: '算法工程师',
          company: '百度',
          salary: '30k-50k',
          status: 'rejected',
          statusLabel: '不合适',
          statusClass: 'rejected',
          deliveryDate: '2024-01-12',
          location: '北京',
          jobType: '全职'
        },
        {
          id: '5',
          jobId: 'job5',
          jobTitle: '实习生',
          company: '小红书',
          salary: '300-400/天',
          status: 'delivered',
          statusLabel: '已投递',
          statusClass: 'delivered',
          deliveryDate: '2024-01-11',
          location: '上海',
          jobType: '实习'
        }
      ]
    }
  },
  computed: {
    filteredProgressList() {
      if (this.currentStatus === 'all') {
        return this.progressList
      }
      return this.progressList.filter(item => item.status === this.currentStatus)
    }
  },
  methods: {
    goBack() {
      uni.navigateBack()
    },
    selectStatus(status) {
      this.currentStatus = status
    },
    goToJobDetail(jobId) {
      uni.navigateTo({
        url: `/pages/job-detail/index?id=${jobId}`
      })
    },
    goToJobSearch() {
      uni.switchTab({
        url: '/pages/home/index'
      })
    }
  }
}
</script>

<style scoped>
.delivery-progress-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #f0f9f4 0%, #e8f5e8 100%);
}

/* 顶部导航 */
.header {
  position: relative;
  background: transparent;
  padding: 110rpx 36rpx 40rpx;
  color: #333333;
  display: flex;
  justify-content: center;
  align-items: center;
}

.back-button {
  position: absolute;
  top: 98rpx;
  left: 36rpx;
  z-index: 10;
  width: 64rpx;
  height: 64rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 185, 129, 0.15);
  border-radius: 50%;
  transition: all 0.3s ease;
  border: 1rpx solid rgba(16, 185, 129, 0.2);
}

.back-icon {
  width: 36rpx;
  height: 36rpx;
  opacity: 0.8;
  transition: opacity 0.3s ease;
  filter: brightness(0);
}

.back-button:hover {
  background: rgba(16, 185, 129, 0.25);
  border-color: rgba(16, 185, 129, 0.3);
}

.back-icon:active {
  opacity: 1;
}

.page-title {
  font-size: 36rpx;
  font-weight: 700;
  color: #333333;
  text-align: center;
  flex: 1;
}

/* 筛选按钮 */
.filter-container {
  padding: 0 32rpx 24rpx;
}

.filter-buttons {
  flex-direction: row;
  display: flex;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 24rpx;
  padding: 12rpx;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
}

.filter-btn {
  flex: 1;
  text-align: center;
  padding: 16rpx 0;
  font-size: 28rpx;
  color: #666;
  border-radius: 16rpx;
  margin: 0 8rpx;
  transition: all 0.3s ease;
  cursor: pointer;
}

.filter-btn:first-child {
  margin-left: 0;
}

.filter-btn:last-child {
  margin-right: 0;
}

.filter-btn.active {
  background: #10b981;
  color: white;
  font-weight: 600;
  box-shadow: 0 4rpx 12rpx rgba(16, 185, 129, 0.3);
}

/* 投递进度列表 */
.progress-list-scroll {
  height: calc(100vh - 220rpx);
  padding: 0 32rpx 24rpx;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.progress-list-scroll::-webkit-scrollbar {
  display: none;
}

.progress-container {
  min-height: 100%;
}

.progress-list {
  display: flex;
  flex-direction: column;
  gap: 24rpx;
}

/* 投递卡片 */
.progress-card {
  background: #fff;
  border-radius: 20rpx;
  box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.04);
  padding: 28rpx 24rpx;
  border: 1rpx solid #f5f5f5;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.progress-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4rpx;
  height: 100%;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.progress-card:hover::before {
  opacity: 1;
}

.progress-card:hover {
  transform: translateY(-2rpx);
  box-shadow: 0 8rpx 24rpx rgba(0,0,0,0.08);
  border-color: rgba(16, 185, 129, 0.1);
}

.job-title-row {
  flex-direction: row;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16rpx;
}

.job-title {
  font-size: 32rpx;
  font-weight: 700;
  color: #222;
  flex: 1;
  margin-right: 16rpx;
}

.job-salary {
  color: #333333 !important;
  font-size: 32rpx;
  font-weight: normal !important;
}

.job-company-row {
  flex-direction: row;
  display: flex;
  align-items: center;
  margin-bottom: 16rpx;
}

.company {
  color: #666;
  font-size: 26rpx;
  margin-right: 16rpx;
}

.tag {
  font-size: 22rpx;
  padding: 8rpx 16rpx;
  border-radius: 16rpx;
  margin-right: 12rpx;
  font-weight: 500;
  border: 1rpx solid;
}

.tag.delivered {
  background: rgba(59, 130, 246, 0.08);
  color: #3b82f6;
  border-color: rgba(59, 130, 246, 0.1);
}

.tag.rejected {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.1);
}

.tag.pending {
  background: rgba(245, 158, 11, 0.08);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.1);
}

.tag.interviewed {
  background: rgba(16, 185, 129, 0.08);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.1);
}

.job-meta {
  flex-direction: row;
  display: flex;
  align-items: center;
  gap: 16rpx;
  margin-bottom: 0;
}

.meta {
  color: #999;
  font-size: 24rpx;
}

/* 加载状态 */
.loading {
  display: flex;
  flex-direction: column;
  gap: 24rpx;
}

.skeleton {
  background: #fff;
  border-radius: 24rpx;
  padding: 32rpx 24rpx;
}

.skeleton-line {
  height: 32rpx;
  background: linear-gradient(90deg, #f2f2f2 25%, #e6e6e6 37%, #f2f2f2 63%);
  background-size: 400% 100%;
  border-radius: 8rpx;
  animation: shimmer 1.5s infinite;
  margin-bottom: 16rpx;
}

.skeleton-line.title {
  width: 60%;
}

.skeleton-line.company {
  width: 40%;
}

.skeleton-line.meta {
  width: 80%;
  margin-bottom: 0;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 120rpx 40rpx;
  text-align: center;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 24rpx;
  margin: 24rpx;
  backdrop-filter: blur(10rpx);
}

.empty-icon {
  font-size: 100rpx;
  margin-bottom: 32rpx;
  opacity: 0.7;
  filter: grayscale(0.3);
}

.empty-text {
  font-size: 32rpx;
  color: #333;
  font-weight: 600;
  margin-bottom: 12rpx;
}

.empty-desc {
  font-size: 26rpx;
  color: #666;
  margin-bottom: 48rpx;
  line-height: 1.5;
}

.publish-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 28rpx;
  padding: 20rpx 48rpx;
  font-size: 30rpx;
  font-weight: 600;
  box-shadow: 
    0 12rpx 32rpx rgba(16, 185, 129, 0.25),
    0 6rpx 16rpx rgba(16, 185, 129, 0.15);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  letter-spacing: 1rpx;
}

.publish-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.6s ease;
}

.publish-btn:hover::before {
  left: 100%;
}

.publish-btn:hover {
  transform: translateY(-3rpx);
  box-shadow: 
    0 16rpx 40rpx rgba(16, 185, 129, 0.35),
    0 8rpx 20rpx rgba(16, 185, 129, 0.25);
}

.publish-btn:active {
  transform: translateY(-1rpx) scale(0.98);
  box-shadow: 
    0 8rpx 24rpx rgba(16, 185, 129, 0.3),
    0 4rpx 12rpx rgba(16, 185, 129, 0.2);
}
</style>